# Contributer: Fabian Affolter <fabian@affolter-engineering.ch>
# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Contributor: Jiri Kastner <cz172638@gmail.com>
# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=py3-cherrypy
_pkgreal=CherryPy
pkgver=18.7.0
pkgrel=0
pkgdesc="A pythonic, object-oriented web development framework"
url="https://cherrypy.dev/"
arch="noarch"
license="BSD-3-Clause"
depends="py3-cheroot py3-jaraco.collections py3-portend py3-zc.lockfile"
# py3-setuptools_scm is needed to set python module version
makedepends="py3-build py3-installer py3-setuptools py3-setuptools_scm py3-wheel"
checkdepends="py3-cheroot-tests py3-path py3-pytest py3-pytest-cov py3-requests-toolbelt py3-tz"
subpackages="$pkgname-tutorial"
source="https://files.pythonhosted.org/packages/source/C/CherryPy/CherryPy-$pkgver.tar.gz
	tests.patch
	test_timeout.patch
	gziptest.patch
	"
builddir="$srcdir/$_pkgreal-$pkgver"
replaces="py-cherrypy" # Backwards compatibility
provides="py-cherrypy=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	python3 -m build --no-isolation --wheel
}

check() {
	python3 -m installer -d testenv dist/$_pkgreal-$pkgver-py2.py3-none-any.whl
	local sitedir="$(python3 -c 'import site;print(site.getsitepackages()[0])')"
	PYTHONPATH="$PWD/testenv/$sitedir" python3 -m pytest -W ignore::DeprecationWarning -W ignore:"unclosed ":ResourceWarning \
		--deselect=cherrypy/test/test_session.py::MemcachedSessionTest \
		--deselect=cherrypy/test/test_caching.py::CacheTest::test_antistampede \
		--deselect=cherrypy/test/test_static.py::StaticTest::test_file_stream
}

package() {
	python3 -m installer -d "$pkgdir" dist/$_pkgreal-$pkgver-py2.py3-none-any.whl

	rm -rf "$pkgdir"/usr/lib/python3*/site-packages/cherrypy/test
}

tutorial() {
	pkgdesc="files for cherrypy tutorial"
	amove usr/lib/python3*/site-packages/cherrypy/tutorial
}

sha512sums="
321771a3e3cda16090bfb7a79c297defd67655ba5453e440e09e85fec41cba850544bebac7203206c95e38d79b3bce22368ea19c0fb1fbedbb00d76a4ab59c8b  CherryPy-18.7.0.tar.gz
64d5e51822fca9045f76894a4e5322b80b2c7826eea21fc97e81bffe419a5f940481b807dad70eee53e4a31bc3598ed10252e7ae97c1d7dcb7ba4085ab3298d6  tests.patch
5d926f538f456e6b58de4c02da51bfa327c71a506bb5fc251303aa4838b311179324245401ec9c5af3043d7d31a3ee211d26344b12c82fc9ed36d666344b45da  test_timeout.patch
cc0384514a3cef41cbfcc441ba66a26feaf71cbd7ab092c8281782dfdfdccaa20cf5facf414e97cb88dd8e7c377067c8b6afdef4f71f22dee4c60db6a02c483b  gziptest.patch
"
